home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 428 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  3.2 KB

  1. From: hickeyr@ibm.net (Rich Hickey)
  2. Message-ID: <4gcjhn$399u@news-s01.ny.us.ibm.net>
  3. X-Original-Date: 20 Feb 1996 13:49:43 GMT
  4. Path: in1.uu.net!bounce-back
  5. Date: 21 Feb 96 07:06:18 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Organization: -
  8. Newsgroups: comp.std.c++
  9. Subject: Re: Q: Generic Callbacks -- "Object->*func(...)"
  10. References: <4fti32$p3p@bcarh8ab.bnr.ca> <4g0csh$dq5@news.bridge.net>
  11. X-Newsreader: NeoLogic News for OS/2 [version: 4.2]
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBFAgUBMSrGmeEDnX0m9pzZAQFp0QGAhoUIcRKI5vnd639iRoejhSs9QmHzZLQ8
  14.     dHzXD5mFAv2zAR92UodXFcRxEApvlcFL
  15.     =b7MV
  16.  
  17. [Moderator's note: my apologies for letting this thread continue,
  18.  since it has strayed from the topic of C++ standardization.  I
  19.  approved this article since I think it would be unfair to deny the
  20.  poster a right of reply in this case (perhaps I shouldn't have
  21.  approved the article to which he is replying).  Anyway, please try to
  22.  make our job as moderators easier by making sure that articles
  23.  submitted are appropriately focussed for this group.  -fjh.]
  24.  
  25. In message <312495AD.757A@ebc.ericsson.se> - Bjorn Fahller 
  26. <ebcbear@ebc.ericsson.se> writes:
  27. :>
  28. :>David Byrden <100101.2547@compuserve.com> wrote:
  29. :>> 
  30. :>> >> I'd like to be able to call "DoIt" with any type of object and a
  31. :>> >> pointer to any of that object's member functions that match the
  32. :>> >> 'parmlist'
  33. :>> 
  34. :>>  In the C++ Report, February 1995, Richard Hickey suggested a library of
  35. :>> universal callback functors which would encapsulate both an object
  36. :>> reference and a pointer to a member function of that object.
  37. :>> 
  38. :>>  The caller, and the provider of the callback, would not have to share
  39. :>> any type information other than the callback library itself.
  40. :>
  41. :>Unfortunately the implementation is all but clean, and depends
  42. :>heavily on the compiler used. Internally, everything is
  43. :>casted to void*. When I tried the implementation on Sun SparcWorks,
  44. :>it failed, since pointer to member functions cannot be casted
  45. :>to void* without severe loss of precision (they're twise
  46. :>as long as void*.)
  47. :>
  48. :>The ideas are still usable, though. Those who are interested
  49. :>can e-mail me for a simple example (not quite as slick as the
  50. :>original, but not compiler dependant since it doesn't use
  51. :>ugly casts.)
  52. :>   _
  53. :>/Bjorn.
  54.  
  55. Unfortunately you must not have understood the implementation.
  56. I admit it is complex, difficult-to-read C++ code, yet it is
  57. quite clean, and at no point are ptrs-to-members cast to void*.
  58. If it doesn't work with your compiler I suggest your compiler
  59. is broken.
  60.  
  61. I suggest you re-read the source quite carefully and make sure
  62. you understand it before you criticize it. The callback library
  63. is being used successfully by many experienced C++ developers.
  64. No one has reported a language-level problem with it.
  65.  
  66. Anyone interested in the library source can decide for 
  67. themselves. It is freely available at:
  68. http://ourworld.compuserve.com/HomePages/RichHickey
  69.  
  70. Rich Hickey
  71. ---
  72. [ To submit articles: try just posting with your news-reader.
  73.                       If that fails, use mailto:std-c++@ncar.ucar.edu
  74.   FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
  75.   Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
  76.   Comments? mailto:std-c++-request@ncar.ucar.edu.
  77. ]
  78.